#include <iostream>
#include<stdio.h>
#include "analysis/parser/CompoundStatement.h"
#include "analysis/SemanticAnalisys.h"
#include "syntesis/ThreeAddress.h"
#include "syntesis/graphs/Graphs.h"

extern CompoundStatement *program;
extern int yyparse();
extern FILE* yyin;

int main ( int argc, char **argv )
{
    const char* filename = "/home/rodolfo/TCC/compiladortcc/src/teste.c";
    SemanticAnalisys *smAnalisy = 0;
	ThreeAddress tai;
    /*	if (argc!=2) {
    		  fprintf(stderr, "usage: %s filename\n", argv[0]);
    			  return 1;
    	}*/
    yyin = fopen ( filename, "r" );
    if ( yyin == NULL )
    {
        std::cerr << argv[0] << ": File " << argv[1] << " cannot be opened.\n";
        return 1;
    }
    yyparse();
    smAnalisy = new SemanticAnalisys ( program );
	tai.makeTable( program ); 
	tai.createLabels();
	Graphs graphs(tai.getThreeAddressTable(), tai.getMapLabels(), tai.getMapBlocks(),tai.getBasicBlocks());
	graphs.generateGraphs();
	tai.print();
//    std::cout << program << std::endl;
    return 0;
}
